package com.zhiwang.xiaoqu.mvp.presenter

import androidSchedule
import com.zhiwang.xiaoqu.di.annotation.ActivityScope
import com.zhiwang.xiaoqu.mvp.model.RestApi
import com.zhiwang.xiaoqu.mvp.model.request.SmsCodeRequest
import responseVoidFunc
import javax.inject.Inject


@ActivityScope
class SmsPresenter @Inject constructor(var restApi: RestApi) {


    fun getBindSmsCode(
        phone: String,
        graphCode: String,
        token: String,
        onSmsSend: (() -> Unit),
        onError: (Throwable) -> Unit
    ) {

        val smsRequest = SmsCodeRequest(phone, graphCode, token)
        smsRequest.setTypeBind()
        with(restApi) {
            getSmsCode(smsRequest)
                .androidSchedule()
                .responseVoidFunc()
                .subscribe({

                }, {
                    onError(it)
                }, {
                    onSmsSend()
                })
        }
    }


}